Ext.define("app.components.ui.list.ComboGridPanel", {
    extend: "Ext.panel.Panel",
    xtype: "combogridpanel_",
    layout: "border",
    //加载默认配置项，外面设置了，这里可以忽略
    config: {
        store: null,
        columns: null,
        codeValueLabel: null,
        codeNameLabel: null,
    },

    initComponent: function () {
        var me=this;
        me.addEvents({"itemdblclick":true});
        me.items = [
            {
                region: "north",
                xtype: "form",
                layout: "hbox",
                height: 35,
                border: false,
                defaultType: "textfield",
                defaults: {
                    margin: 5,
                },
                items: [
                    {
                        labelWidth: "50%",
                        fieldLabel: me.codeValueLabel,
                        name: "value",
                        width: "30%"
                    },
                    {
                        labelWidth: "50%",
                        fieldLabel: me.codeNameLabel,
                        name: "text",
                        width: "50%"
                    },
                    {
                        xtype: "button",
                        text: "查询",
                        handler: function () {
                            var form=this.up("form").getForm();
                            var values=form.getValues();
                            console.log(values);
                            if(values.value!=""&&values.text!=""){
                                var params = me.store.getProxy().extraParams;
                                Ext.apply(params,values);
                            }
                            me.store.loadPage(1);
                        }
                    },
                    {
                        xtype: "button",
                        text: "重置",
                        handler: function () {
                            this.up("form").getForm().reset();
                        }
                    }
                ]
            },
            {
                region: "center",
                border: false,
                items: {
                    xtype: "grid",
                    border: false,
                    store: me.store,
                    columns: me.columns,
                    dockedItems: [
                        {
                            xtype: "pagingtoolbar",
                            store: me.store,
                            dock: "top",
                        }
                    ],
                    listeners:{
                        scope:this.up("panel"),
                        itemdblclick:function (v,r) {
                            me.fireEvent("itemdblclick",v,r);
                        }
                    }
                }
            }
        ];

        me.callParent();
    }
});
